<template>
    <div>
        <h2 class="h2"><span>军籍信息表--复员军人</span></h2>
        <div>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="160px" class="demo-ruleForm junjixinxibiao" id="junjixinxibiao" accept-charset="UTF-8">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="入伍时间：" prop="D001">
                            <el-date-picker v-model="ruleForm.D001" type="date" placeholder="入伍时间"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="原部队代号：">
                            <el-input v-model="ruleForm.D003" id="D003" placeholder="请输入原部队代号（不填番号）"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item class="select2" label="原职级：" prop="D009">
                            <el-cascader
                                :options="options"
                                v-model="ruleForm.D009"
                                @change="handleChange">
                            </el-cascader>   
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item class="select2" label="入伍时户籍性质：" prop="D008">
                            <el-select v-model="ruleForm.D008" placeholder="请选择入伍时户籍性质">
                                <el-option label="城镇" value="1"></el-option>
                                <el-option label="农村" value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="复员时间：" prop="D016">
                            <el-date-picker v-model="ruleForm.D016" type="date" placeholder="复员时间"></el-date-picker>
                        </el-form-item>
                    </el-col> 
                    <el-col :span="12">
                        <el-form-item label="军龄：" prop="D017">
                            <el-input v-model="ruleForm.D017" id="D017" placeholder="请输入军龄："></el-input>
                        </el-form-item>
                    </el-col>       
                </el-row>
                <el-row>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">下一步</el-button>
                        <el-button @click="resetForm('ruleForm')">重置</el-button>
                    </el-form-item>
                </el-row>
            </el-form>
        </div>
    </div>
</template>

<script>
import options from './options.js'
export default {
    data(){
        return {
            options:options,
            ruleForm: { //默认数据
                D001:'',//入伍时间
                D003:'',//原部队代号
                D009:[],//原职级
                D008:'',//入伍时户籍性质
                D016:'',//复员时间
                D017:'',//军龄
            },
            rules: {  //规则
                D001:[
                     { required: true, message: '请填写入伍时间', trigger: 'blur' },
                ],
                D008:[
                    { required: true, message: '请填写入伍时户籍性质', trigger: 'blur' },
                ],
                D009:[
                    { required: true, message: '请填写军休类别', trigger: 'blur' },
                ],
                D016:[
                    { type: 'date', required: true, message: '请选择复员时间', trigger: 'change' }
                ],
                D017:[
                    { required: true, message: '请填写军龄', trigger: 'blur' },
                ]
            },
        }
    },
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    alert('成功，tuiyishibing!');
                    console.log(this.ruleForm)
                    this.$emit('submitfn',2)
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
        hujisuozaidifnsss(value){
            console.log(value)
            this.hujisuozaidiData = value
        },
        hujisuozaidifnsss2(value){
            console.log(value)
        },
    },
    components:{
        
    }
}
</script>

<style scoped>
.el-row {
    margin-bottom: 20px;
}
.el-row:last-child {
    margin-bottom: 0;
}
</style>